// 1.引入封装好的 axios
import request from "@/utils/request"
// 2.引入类型约束

// 3.枚举 Api
enum Api {
  // 1.获取 spu列表数据
  getSpuListDataApi = "/admin/product",
  // 2.添加spu
  saveSpuListDataApi = "/admin/product/saveSpuInfo",
  // 3.更新spu
  updateSpuListDataApi = "/admin/product/updateSpuInfo",
  // 4.删除spu列表数据
  deleteSpuListDataApi = "/admin/product/deleteSpu",

  // 5.获取 spuForm中 spu品牌数据
  getBaseTrademarkListApi ="/admin/product/baseTrademark/getTrademarkList",
  // 6.获取 spuForm中 销售属性 数据
  getBaseSaleAttrListApi = '/admin/product/baseSaleAttrList',
  
  // 7.获取图片列表
  getSpuImageListApi = '/admin/product/spuImageList',
  // 获取基础销售属性列表
  getSpuSaleAttrListApi = '/admin/product/spuSaleAttrList'
}
// 4.书写接口
// 4.1 获取spu列表数据
export const reqGetSpuListData = (page: number, limit: number, category3Id: number) => request.get(`${Api.getSpuListDataApi}/${page}/${limit}?category3Id=${category3Id}`)
// 4.2 获取spuform中 spu品牌数据
export const reqGetSpuFormBaseTrademarkList = () => request.get(Api.getBaseTrademarkListApi)
// 4.3 获取 spuForm中 销售属性 数据
export const reqGetSpuFormBaseSaleAttrList = () => request.get(Api.getBaseSaleAttrListApi)
// 4.4 添加 数据
export const ReqSaveSpuInfo = (spuInfo) => request.post(Api.saveSpuListDataApi, spuInfo)
// 4.5 删除 数据
export const reqDeleteSpuInfo = (spuId: number) => request.delete(`${Api.deleteSpuListDataApi}/${spuId}`)
// 4.6 获取 数据回显 图片列表
export function reqGetSpuImageList(spuId: number) {
  return request.get(Api.getSpuImageListApi + `/${spuId}`)
}
// 4.7 获取属性列表
export function reqGetSpuSaleAttrList(spuId: number) {
  return request.get(Api.getSpuSaleAttrListApi + `/${spuId}`)
}
//  4.8 更新数据
export const reqUpdateSpuInfo=(spuInfo)=>request.post(Api.updateSpuListDataApi,spuInfo)

